package com.lovo.psc.controller;


import com.lovo.psc.entity.UserBean;
import com.lovo.psc.service.IUserService;
import com.lovo.util.PscToKen;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 刘英旭
 * @since 2022-07-07
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService iUserService;

    @PostMapping("register")
    public String register(UserBean userBean) {
        return iUserService.register(userBean.getCommoduser(),
                userBean.getPwd(),
                userBean.getName(),
                userBean.getImg(),
                userBean.getClasses());
    }

    @GetMapping("login/{user}/{pwd}")
    public String login(@PathVariable("user") String user,@PathVariable("pwd") String pwd){
        return iUserService.login(user,pwd);
    }

    @PostMapping("verifierPsc/{ToKen}")
    public UserBean verifierPsc(@PathVariable("ToKen") String ToKen){
        return PscToKen.verifierJwt(ToKen);
    }


    /**
     * 根据供应商编号修改状态
     * @param supplierNumber 经销商编号
     * @param info 状态 1,审核通过，或者写入失败原因
     */
    @PutMapping("upDataSupplierState/{supplierNumber}/{info}")
    public void upDataSupplierState(@PathVariable("supplierNumber") String supplierNumber,@PathVariable("info") String info){
        iUserService.upDataSupplierState(supplierNumber,info);
    }
}
